package com.pengcheng.taskapplication.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;


import com.pengcheng.taskapplication.model.TabItem;

import java.util.List;

/**
 * <p></p>
 */
public class FragmentAdapter extends FragmentPagerAdapter {

    private List<TabItem> titles;
    private List<Fragment> newsFragmentList;

    public FragmentAdapter(FragmentManager fm, List<TabItem> titles, List<Fragment> newsFragmentList) {
        super(fm);
        this.titles = titles;
        this.newsFragmentList = newsFragmentList;
    }

    public FragmentAdapter(FragmentManager fm, List<TabItem> titles, List<Fragment> newsFragmentList, List<Integer> counts) {
        super(fm);
        this.titles = titles;
        this.newsFragmentList = newsFragmentList;
    }
    @Override
    public Fragment getItem(int position) {
        return newsFragmentList.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position).getName();
    }

    @Override
    public int getCount() {
        return newsFragmentList.size();
    }

}
